package com.example.peibei.ui.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dingtao.common.bean.HomeBannerCate;
import com.dingtao.common.bean.HomeCateTwo;
import com.example.peibei.R;
import com.example.peibei.bean.Cate;

import java.util.List;

public class HomeCateAdapter extends BaseQuickAdapter<HomeCateTwo.CategoryDTO, BaseViewHolder> {
    public HomeCateAdapter(@Nullable List<HomeCateTwo.CategoryDTO> data) {
        super(R.layout.item_home_cate, data);
    }

    public HomeCateAdapter() {
        super(R.layout.item_home_cate);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeCateTwo.CategoryDTO item) {
        helper.setText(R.id.tv_cate, item.getCaption());
        ImageView head = helper.getView(R.id.iv_cate);
        if (!TextUtils.isEmpty(item.getIcon())) {
            Glide.with(getContext()).load(item.getIcon()).into(head);
        } else {
            helper.setImageResource(R.id.iv_cate, R.mipmap.cate_defalut);
        }
    }
}
